import * as echarts from 'echarts'
import { useEffect, useRef } from 'react'
function Bar ({ style, xData, yData, title, Zsatisfaction, ZdegreeUse }) {
  const echartsRef = useRef()
  const echartsInit = () => {
    // 基于准备好的dom，初始化echarts实例
    var myChart = echarts.init(echartsRef.current)
    // 绘制图表
    myChart.setOption({
      title: {
        text: title
      },
      tooltip: {},
      xAxis: {
        data: xData
      },
      yAxis: {},
      series: [
        {
          name: Zsatisfaction || ZdegreeUse,
          type: 'bar',
          data: yData,
        }
      ]
    })
  }
  // 使用Dom
  useEffect(() => {
    echartsInit()
  })

  return (
    <div >
      <div ref={echartsRef} style={style}></div>
    </div >
  )
}
export default Bar